package com.andnnl.redis;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.util.Set;

/**
 * Created by chenss on 2020/11/4.
 */
public class TestMobileRedis {
    private static final Logger logger = LoggerFactory.getLogger(TestMobileRedis.class);
    public static void main(String[] args) {
//        testInsert();
//        testInsertSet();
        testScanSet();

    }

    private static void testScanSet() {
        long a = 13800010001L;
        byte[] x = Utilities.long2Bytes(a);
        logger.info(""+x);
        byte[] key="bl".getBytes();
        byte[] value = new byte[]{1};
        RedisSessionOld.operate(s -> {
            for (int i = 0; i < 100; i++) {
                double mobile=a + i;
                System.out.println(mobile);
                Set<byte[]> rs = s.zrangeByScore(key, mobile, mobile);
                System.out.println(rs);
                if(i%10000==0){
                    logger.info(""+i);
                }
            }
            return null;
        });
    }

    private static void testInsertSet() {
        long a = 13800010001L;
        byte[] x = Utilities.long2Bytes(a);
        logger.info(""+x);
        byte[] key="bl".getBytes();
        byte[] value = new byte[]{1};
        RedisSessionOld.operate(s -> {
            for (int i = 0; i < 100; i++) {
                double mobile=a + i;
                System.out.println(mobile);
                s.zadd(key,mobile,value);
                if(i%10000==0){
                    logger.info(""+i);
                }
            }
            return null;
        });
    }
    private static void testInsert() {
        long a = 13800010001L;
        byte[] x = Utilities.long2Bytes(a);
        logger.info(""+x);

        byte[] value = new byte[]{1};
        RedisSessionOld.operate(s -> {
            for (int i = 0; i < 100000000; i++) {
                byte[] bs = Utilities.long2Bytes(a + i);
                s.setex(bs,value,5*60);//5分钟
                if(i%10000==0){
                    logger.info(""+i);
                }
            }
            return null;
        });
    }

}
